/* GUI CONVERTED from rcrsupc1.p (converter v1.75) Sat Aug 12 23:01:16 2000 */
/* rcrsupc1.p - Release Management Customer Schedules                   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*V8:ConvertMode=Maintenance                                            */
/*K1Q4*/ /*V8:WebEnabled=No                                             */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96           BY: TSI *K005*    */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98           BY: *K1Q4* Alfred Tan */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00           BY: *N0KP* myb        */


         /* REQUIRED SCHEDULE UPDATE SUBPROGRAM */


         {mfdeclre.i}

         /*INPUT PARAMETERS*/
         define input parameter soddet_recid as recid no-undo.
         define input parameter new_discr_qty as decimal no-undo.
         define input parameter prev_discr_qty as decimal no-undo.
         define input parameter prev_all_qty as decimal no-undo.
         define input parameter prev_ship_qty as decimal no-undo.

         /*OUTPUT PARAMETERS*/
         define output parameter undo_status as logical no-undo.

         /*LOCAL VARIABLES*/
         define variable act_prcnt_ship as integer no-undo.
         define variable new_prcnt_ship as integer no-undo.
         define variable shp_peg_qty as decimal no-undo.
         define variable ship_cmplt as decimal no-undo.
         define variable msgtext as character no-undo.
         define variable errlevel as integer no-undo.
         define variable errgen as logical no-undo.


         find sod_det
            where recid(sod_det) = soddet_recid
            no-lock.

         find so_mstr
            where so_nbr = sod_nbr
            no-lock.


         assign
            errgen         = false
            undo_status    = true
            shp_peg_qty    = prev_ship_qty + prev_all_qty
            ship_cmplt     = if so_ship_cmplt = 0
                                then 100 else so_ship_cmplt
            act_prcnt_ship = integer((prev_ship_qty /
                                prev_discr_qty) * 100)
            new_prcnt_ship = integer((prev_ship_qty /
                                new_discr_qty) * 100).

            /********************************************/
            /* CHECK IF THE CHANGED REQ QTY IS NOW MORE */
            /* THAN SHIPPED + PEGGED.                   */
            /********************************************/
            if new_discr_qty > shp_peg_qty
               and prev_discr_qty <= shp_peg_qty
               and shp_peg_qty <> 0 then
            do:
               msgtext = string(prev_ship_qty) + "/" +
                         string(prev_all_qty).

               {gprun.i ""gpcfmsg.p"" "(input 1523,
                    input 0,
                    input program-name(1),
                    input so_site,
                    input so_ship,
                    input msgtext,
                    input true,
                    output errlevel)"}
/*GUI*/ if global-beam-me-up then undo, leave.

                pause.

                errgen = if errlevel > 2 then true else errgen.

            end.


            /********************************************/
            /* CHECK IF THE CHANGED REQ QTY IS NOW LESS */
            /* THAN SHIPPED + PEGGED.                   */
            /********************************************/
            if new_discr_qty < shp_peg_qty
               and prev_discr_qty >= shp_peg_qty
               and shp_peg_qty <> 0 then
            do:
               msgtext = string(prev_ship_qty) + "/" +
                         string(prev_all_qty).

               {gprun.i ""gpcfmsg.p"" "(input 1524,
                    input 0,
                    input program-name(1),
                    input so_site,
                    input so_ship,
                    input msgtext,
                    input true,
                    output errlevel)"}
/*GUI*/ if global-beam-me-up then undo, leave.

               pause.

               errgen = if errlevel > 2 then true else errgen.

            end.


            /********************************************/
            /* CHECK IF THE CHANGED REQ QTY WILL NOW    */
            /* MAKE THE PERCENTAGE SHIPPED MORE THAN    */
            /* THE REQUIRED PERCENTAGE FOR COMPLETION   */
            /* FLAG.                                    */
            /********************************************/
            if new_prcnt_ship > ship_cmplt
               and act_prcnt_ship <= ship_cmplt then
            do:
               msgtext = string(act_prcnt_ship) + "/" +
                         string(new_prcnt_ship) + "/" +
                         string(ship_cmplt).

               {gprun.i ""gpcfmsg.p"" "(input 1525,
                    input 0,
                    input program-name(1),
                    input so_site,
                    input so_ship,
                    input msgtext,
                    input true,
                    output errlevel)"}
/*GUI*/ if global-beam-me-up then undo, leave.

               pause.

               errgen = if errlevel > 2 then true else errgen.

            end.


            /********************************************/
            /* CHECK IF THE CHANGED REQ QTY WILL NOW    */
            /* MAKE THE PERCENTAGE SHIPPED LESS THAN    */
            /* THE REQUIRED PERCENTAGE FOR COMPLETION   */
            /* FLAG.                                    */
            /********************************************/
            if new_prcnt_ship < ship_cmplt
               and act_prcnt_ship >= ship_cmplt then
            do:
               msgtext = string(act_prcnt_ship) + "/" +
                         string(new_prcnt_ship) + "/" +
                         string(ship_cmplt).

               {gprun.i ""gpcfmsg.p"" "(input 1527,
                    input 0,
                    input program-name(1),
                    input so_site,
                    input so_ship,
                    input msgtext,
                    input true,
                    output errlevel)"}
/*GUI*/ if global-beam-me-up then undo, leave.

               pause.

               errgen = if errlevel > 2 then true else errgen.

            end.

            if errgen then
               return.

         undo_status = false.
